package com.qf.service.impl;
/*
   @author 86155
   @ClassName: com.qf.service.impl.ProductServiceImpl
   @Description: 该类的功能描述
   @date: 2021/9/30 9:43 
*/

import com.github.pagehelper.PageHelper;
import com.qf.entity.Banner;
import com.qf.entity.Product;
import com.qf.mapper.ProductMapper;
import com.qf.request.RequestProductParams;
import com.qf.service.ProductService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ProductServiceImpl implements ProductService {
    @Resource
    private ProductMapper productMapper;

    @Override
    public int addProduct(RequestProductParams requestProductParams) {
        Product product = new Product();
        BeanUtils.copyProperties(requestProductParams,product);
        return productMapper.insertProduct(product);
    }

    @Override
    public Integer updateProduct(RequestProductParams requestProductParams) {
        Product product = new Product();
        BeanUtils.copyProperties(requestProductParams,product);
        return productMapper.updateProduct(product);
    }

    @Override
    public Integer deleteProduct(Long pid) {
        return productMapper.deleteProduct(pid);
    }

    @Override
    public List<Product> selectAllProduct(Integer status,String productName, Integer page, Integer size) {
        PageHelper.startPage(page, size);
        return productMapper.selectAllProduct(status,productName);
    }
}
